﻿use LibraryDB
go
if exists(select * from sysobjects where name='usp_AddBook')
drop procedure usp_AddBook
go
create procedure usp_AddBook
@BarCode varchar(20), 
@BookName varchar(100), 
@Author varchar(50), 
@PublisherId int, 
@PublishDate smalldatetime,
@BookCategory int, 
@UnitPrice numeric(18,2),
@BookImage text, 
@BookCount int,
@Remainder int, 
@BookPosition varchar(20)
as


insert into Books(BarCode, BookName, Author, PublisherId, PublishDate, BookCategory, UnitPrice, BookImage, BookCount, Remainder, BookPosition)
values(@BarCode, @BookName, @Author, @PublisherId, @PublishDate, @BookCategory, @UnitPrice, @BookImage, @BookCount, @Remainder, @BookPosition)
go


use LibraryDB
go
if exists(select * from sysobjects where name='usp_EditBook')
drop procedure usp_EditBook
go
create procedure usp_EditBook
@BookName varchar(100),
@Author varchar(50),
@PublisherId int,
@PublishDate smalldatetime,
@BookCategory int,
@UnitPrice numeric(18,2),
@BookImage text,
@BookCount int,
@BookId int
as
	update Books set BookName=@BookName,Author=@Author,PublisherId=@PublisherId,PublishDate=@PublishDate,
	BookCategory=@BookCategory,UnitPrice=@UnitPrice,BookImage=@BookImage,BookCount=@BookCount
	where BookId=@BookId
go